'''
Created on Nov 26, 2012

@author: jason.richmond
'''
import re
from django import forms

class StudentForm(forms.Form):
    firstName = forms.CharField()
    lastName = forms.CharField()
    email = forms.EmailField()
    
class RegisterForm(forms.Form):
    umid = forms.CharField()
    firstName = forms.CharField(max_length=45)
    lastName = forms.CharField(max_length=45)
    title = forms.CharField(max_length=45)
    email = forms.EmailField(max_length=45)
    phone = forms.CharField(max_length=45)
    
    '''
    Server-side form validation by defining clean function for field you want to validate
    '''
    
    def clean_umid(self):
        umid = self.cleaned_data['umid']
        match = re.match('[0-9]{8}', umid)
        if not match:
            raise forms.ValidationError("UMID must be 8 numbers.")
        return umid